Integrate ServiceNow CI properties into SevOne
Overview
In this lab we will review how we can copy the attributes available in ServiceNow into SevOne metadata.
The flow of this lab is the following:
We get the list of current CIs in a table in ServiceNow
For each of the CIs on ServiceNow, we will check if that CI exists in SevOne
If the device exists, we will get the list of all the properties available in the CI
For each of the properties we will check if they are a single value property or a 'link' property (ServiceNow has two types of properties)
Depending on the type of property, we will push the data into SevOne using the appropiate metadata attribute type (text or URL)
Prerequirements
In order to complete this lab, it is required to have access to a ServiceNow instance. If you don't have one already, please create one using following the steps defined on this link.
It's important to change your role to admin to be able to use the instance properly (see link here )
We strongly recommend doing the 'Sync Sevone Devices with ServiceNow' lab first to have the same devices in both platforms
ServiceNow - SevOne metadata sync
If SevOne authentication has already been created, please skip this block of actions and continue to step 4.
Log into SANO automation platform
Go to Authentications
Click Create Authentication
a. Name: SevOne
b. Service: SevOne
c. Protocol: http:// (<-- important)
d. Host: 10.0.0.10
e. Username: admin
f. Password: SevOne
If ServiceNow authentication has already been created, please skip this block of actions and continue to step 5.
Click Create Authentication
a. Name: ServiceNow
b. Service: ServiceNow
c. Protocol: https://
d. Host: (Your SNOW instance URL, example: dev109667.service-now.com)
e. Username: (Your SNOW instance username, example: admin)
f. Password: (Your SNOW instance password)
Go to Workflows
Click Create Workflow
a. Name: Sync ServiceNOW properties with SevOne metadata
b. Layout type: Sequence
Add variables to Start
a. NMSCredentials
i. Name: NMSCredentials
ii. Type: Authentication -> SevOne
iii. Default Value: "admin/SevOne"
iv. In
v. Requiredb. ServiceNowCredentials
i. Name: ServiceNowCredentials
ii. Type: Authentication -> ServiceNow
iii. Default Value: "admin/ServiceNow"
iv. In
v. Requiredc. namespace
i. Name: namespace
ii. Type: string
iii. Default Value: "ServiceNow"
iv. In
v. Required
Change to Flow View
On the left hand side panel, Click on ServiceNow
Select "getTable" and drop it after the building block START
a. Change name to ServiceNow_Get_CIs
b. Click on the building block to open the right side panel and complete the following fields
i. authKey: $ServiceNowCredentials
ii. tableName: "cmdb_ci_ip_device"Add a new building block, Common -> ForEach
a. Change name to ForEach_CI
b. Click on the building block to open the right side panel and complete the following fields
i. list: $ServiceNow_Get_CIs.result.result
Inside the LOOP, add a new building block, SevOne -> REST v3 -> Metadata Devices (POST)
a. Change name to SevOne_Find_Device
b. Click on the building block to open the right side panel and complete the following fields
i. authKey: $NMSCredentials
ii. body -> name -> value: $ForEach_CI.item.name
Add a new building block, Common -> If
a. Change name to If_Device_Found
b. Click on the building block to open the right side panel and complete the following fields
i. condition: $SevOne_Find_Device.result.devices.length > 0
In the 'TRUE' branch of the If, add a new building block, Common -> Object -> Object Keys
a. Change name to Properties
b. Click on the building block to open the right side panel and complete the following fields
i. Object: OneOf -> Object
1. Click Ok
2. Click on the pencil icon
3. Type $ForEach_CI.item
Add a new building block, Common -> ForEach
a. Change name to ForEach_Property
b. Click on the building block to open the right side panel and complete the following fields
i. list: $Properties.result
Inside the LOOP, add a new building block, Common -> Validation -> Is Object
a. Change name to IsObject
b. Click on the building block to open the right side panel and complete the following fields
i. item: $ForEach_CI.item[$ForEach_Property.item]
Add a new building block, Common -> If
a. Change name to If_Obkect
b. Click on the building block to open the right side panel and complete the following fields
i. condition: $IsObject.result
In the 'TRUE' branch of the If, add a new building block, SevOne -> REST v3 -> Metadata Admin -> Metadata Admin Patch Device Metadata
a. Change name to SevOne_Update_Metadata_Object
b. Click on the building block to open the right side panel and complete the following fields
i. authKey: $NMSCredentials
ii. body:
1. attribute: $ForEach_Property.item
2. deviceId: $SevOne_Find_Device.result.devices[0].id
3. namespace: $namespace
4. url -> values: [{"label": $ForEach_CI.item[$ForEach_Property.item].value,"url": $ForEach_CI.item[$ForEach_Property.item].link }]In the 'FALSE' branch of the If, add a new building block, SevOne -> REST v3 -> Metadata Admin -> Metadata Admin Patch Device Metadata
a. Change name to SevOne_Update_Metadata
b. Click on the building block to open the right side panel and complete the following fields
i. authKey: $NMSCredentials
ii. body:
1. attribute: $ForEach_Property.item
2. deviceId: $SevOne_Find_Device.result.devices[0].id
3. namespace: $namespace
4. text -> [$ForEach_CI.item[$ForEach_Property.item]]
Review
To test the workflow, click on Run
Go to SevOne (vPAS)
Go to any of the devices listed, for example CHI-AP01 and click on the 'Metadata' icon
- Scroll down until you see 'ServiceNow', there you will see all the properties from ServiceNow copied into SevOne metadata